<?php
//session_start();
require("../basicInfo/user.php");

$UserNameIsEmpty = false;
$passwordIsEmpty = false;

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if ($_POST["uname"]=="") {
        $UserNameIsEmpty = true;
    }
    if ($_POST["password"]=="")
        $passwordIsEmpty = true;


if(!$UserNameIsEmpty && !$passwordIsEmpty)
$userId = UserController::get_user_id_by_username_password($_POST["uname"],$_POST["password"]);

if ($userId) {
    $userinfo=UserController::obtain_user($_POST["uname"]);
      $serialzedUser = serialize($userinfo);
        $_SESSION['userinfo']=$serialzedUser;
        $_SESSION['logged_in']="true";
        echo '<script language="javascript">location.replace("profile.php");</script>';
        //header('Location: profile.php' );
        exit;
}
}
if ($_SERVER["REQUEST_METHOD"] == "POST")
    $fullr = array("User_Name" => $_POST["uname"],
        "Password" => $_POST["password"]);
else
    $fullr = array("User_Name"=>"",
        "Password" => "");
?>
